<extend name="Layout:layout_list" />
<block name="body_content_block">
<div>
    <a class="easyui-linkbutton lnk-reboot" href="#">重启系统</a>
    <a class="easyui-linkbutton lnk-web" href="{:AddonU('Status/system_restart_service','type=web')}">重启WEB</a>
    <a class="easyui-linkbutton lnk-db" href="{:AddonU('Status/system_restart_service','type=db')}">重启数据库</a>
    <a class="easyui-linkbutton lnk-countdown" href="#" data-func="refresh_iframe()">刷新</a>
</div>
<iframe id="ifPage" src="/admin/config.php?soview=iframe&apptil={$Think.config.USER.USER_KEY}" width="668" height="610" frameborder="0" scrolling="no"></iframe>
<form method="post" id="frmsys" action="/admin/config.php?display=sysadmin&view=power" style="display: none;"><input type="hidden" name="action" value="power"/></form>
</block>
<block name="body_after_block">
<script type="text/javascript">
    function refresh_iframe() {
        $('#ifPage').attr('src', $('#ifPage').attr('src'));
    }
    $('.lnk-reboot').click(function () {
        if (!confirm('您确定要重启系统吗?\n重启系统将停止所有呼叫!')) {
            return false;
        }
        var answer = prompt ("为防止误操作,请输入重启验证码: \"reboot\":");
        if (answer != 'reboot') {
            return false;
        }
        var form = $('#frmsys');
        $.ajax({
            type: "POST",
            url: form.attr('action'),
            data: form.serialize() + "&power=Reboot",
            error: function (xhr, status, error) {
                alert('出错了，请重试!');
            },
            success: function (response) {}
        });
        alert('系统正在重启，请等待5分钟后刷新此页!');
        return false;
    })
    $('.lnk-db, .lnk-web').click(function(){
        if(!confirm('您确定要重启服务吗？')){
            return false;
        }
        $.get($(this).attr('href'),function(data){
            //alert(data);
        });
        alert('正在重启服务，请等待1分钟后刷新此页!');
        return false;
    })
</script>
</block>